(function($){
	var zindex = 100;
	$.dialog = {
		_op:{url:"",title:"窗口",height:400,width:580,buttons:null,max:true},
		open:function(options){
			var op = $.extend({},$.dialog._op, options);
			var time = (new Date()).getTime();
			$("body").css({"overflow":"hidden"}).append('<div id="bg_'+time+'" class="modal-bg"></div>');
			zindex += 1;
			$("#bg_"+time).css({"z-index":zindex});
			$("body").append("<div id='dialog_"+time+"' class='dialog-frame'><h4 class='dialog-title'><span class='dialog-ico'></span>"+op.title+"<span class='close'></span></h4></div>");
			zindex += 1;
			$("#dialog_"+time).css({left:"50%",top:"50%","margin-left":-op.width/2+"px","margin-top":-op.height/2+"px","z-index":zindex});
			$("#dialog_"+time).append("<iframe id='iframe_"+time+"' src='"+op.url+"'></iframe>");
			$("#iframe_"+time).css({width:op.width+"px",height:op.height+"px",border:"0"});
			$(".close").on("click",function(){
				$.dialog.close(time);
			});
			if(op.buttons != null){
				$("#dialog_"+time).append("<div id='buttons_"+time+"' class='buttons'></div>");
				$(op.buttons).each(function(i,item){
					$("#buttons_"+time).append("<input type='button' class='btn btn-default btn-x' value='"+item.text+"' />");
					$("#buttons_"+time+" input:eq("+i+")").on("click",function(){
						item.click($.dialog,time);
					});
				});
			}
		},
		close:function(time){
			$("body").css({"overflow":"none"});
			$("#bg_"+time+",#dialog_"+time).remove();
		},
		paras:function(time){
			return $(window.parent.document).contents().find("#iframe_"+time)[0].contentWindow;
		}
	};
})(jQuery)
